#include "areas.h"
#include "Float.h"

Float calculo_de_parentesis(Float a, Float b, Float c, unsigned int t);
Float max(Float a, Float b);
Float min(Float a, Float b);

Float heron(Float &u, Float &v, Float &w, unsigned int t)
{
	Float s = (u + v + w) / Float(2.0, t);
	return ( Float::raiz(s*(s-u)*(s-v)*(s-w)) );
}

Float diferencias_faciales(Float u, Float v, Float w, unsigned int t)
{
	Float A = (u - v + w);
	A *= (w - u + v);
	A *= (v - w + u);
	A *= (u + v + w);

	return ( (Float::raiz(A)) / Float(4.0, t) );
}

Float dif_faciales_revisado(Float u, Float v, Float w, unsigned int t)
{
	Float A = calculo_de_parentesis(u, v, w, t);
	A *= calculo_de_parentesis(w, u, v, t);
	A *= calculo_de_parentesis(v, w, u, t);
	A *= (u + v + w);
	
	return ( (Float::raiz(A)) / Float(4.0, t) );
}

Float calculo_de_parentesis(Float a, Float b, Float c, unsigned int t)
{
	Float res (max(a, c) - b);
	res += min(a,c);
	return res;
}

Float max(Float a, Float b){
	return a <= b ? b : a;
}

Float min(Float a, Float b){
	return a < b ? a : b;
}

